#encoding:utf-8
import cv2
import numpy as np
#找到要跟踪对象的黑色颜色的HSV值
img=cv2.imread('g.jpg')

hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)

lower_blue=np.array([0,0,0])
# upper_blue=np.array([179,255,46])#标准
upper_blue=np.array([179,255,40])




mask=cv2.inRange(hsv,lower_blue,upper_blue)
res=cv2.bitwise_and(img,img,mask=mask)


a = 5
kernel = np.ones((a),np.float32)/(a*a)
dst = cv2.filter2D(mask,-1,kernel)

blur = cv2.blur(mask,(5,5))

gaosi = cv2.GaussianBlur(mask,(5,5),0)

median = cv2.medianBlur(mask,5)

shuangbian = cv2.bilateralFilter(mask,9,75,75)
cv2.imshow("img",img)
# cv2.imshow('res',res)
cv2.imshow('mask',mask)
cv2.imshow('dst',dst)
cv2.imshow('blur',blur)
cv2.imshow('gaosi',gaosi)
cv2.imshow('median',median)
cv2.imshow('shuangbian',shuangbian)

k = cv2.waitKey()
if k == 27:
	cv2.destroyWindows()

